<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>欢乐谷</title>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <link rel="stylesheet" href="/new/layui/css/layui.css">
    <link rel="stylesheet" href="/new/css/entertain/x-admin.css" media="all">
    <script type="text/javascript" src="/new/js/entertain/xadmin.js"></script>
</head>
<body>
<div class="x-nav">
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh-3" style="line-height:50%"></i></a>
</div>
<button class="layui-btn" onclick="add()"><i class=" layui-icon layui-icon-add-circle"></i>添加</button>
<a href="/manager/excel?a=1"  class="layui-btn"><i class="layui-icon layui-icon-table"></i>excel导出</a>
<table class="layui-table" lay-even lay-skin="nob"   style="table-layout:fixed">
    <thead>
    <th>ID</th>
    <th>主题</th>
    <th>简介</th>
    <th>包含设施</th>
    <th>操作</th>
    </thead>
    <tbody>
    <tr th:each="x:${entertainment}">
        <td th:text="${x.entertainmentId}"></td>
        <td th:text="${x.entertainmentName}"></td>
        <td style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"  th:text="${x.entertainmentContent}" th:title="${x.entertainmentContent}"></td>
        <td>
            <ul th:each="y:${x.facilityList}" style="list-style-type: none">
                <li th:text="${y.facilityName}" ></li>
            </ul>
        </td>
        <td>
            <a title="编辑"  onclick="update(this)" href="javascript:;">
                <i class="layui-icon layui-icon-edit"></i>
            </a>
            <a title="删除" onclick="del(this,'要删除的id')" href="javascript:;">
                <i class="layui-icon layui-icon-delete"></i>
            </a>
        </td>
    </tr>
    </tbody>
</table>

<script src="/new/layui/layui.js" charset="utf-8">
</script>
<script src="/new/js/entertain/x-layui.js" charset="utf-8">
</script>
<script>
    function update(obj) {
        var id=$(obj).parents("tr").find("td").eq(0).text();
        console.log(JSON.stringify(id));
        var url ='/manager/entertainmentmodify?id='+id
        x_admin_show('主题修改',url)
    }
    function add() {
        x_admin_show('主题添加','/manager/addentertainment')
    }
    function del(obj){
        var id=$(obj).parents("tr").find("td").eq(0).text();
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                url : "/manager/delentertainment",
                type : "post",
                contentType: "application/json",
                data : JSON.stringify(id),
                success : function (data) {
                    if (data.status == 200) {
                        $(obj).parents("tr").remove();
                        layer.alert(data.message);
                    } else {
                        layer.alert(data.message);
                    }
                },
                error : function (data) {
                    layer.alert(data.responseText);
                }
            })
        })}
</script>
</body>
</html>